package com.example.demo.service.impl;

import com.example.demo.service.AsyncService;
import com.example.demo.utils.ImageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class AsyncServiceImpl implements AsyncService {

    private static final Logger logger = LoggerFactory.getLogger(AsyncServiceImpl.class);

    @Override
    @Async("asyncServiceExecutor")
    public void executeAsync(File upload) {
        logger.info("start executeAsync 开始执行线程");
        try{
//            Thread.sleep(1000);
            ImageUtil.reSize(upload,upload, 1000, 1000, true);
        }catch(Exception e){
            e.printStackTrace();
        }
        logger.info("end executeAsync 结束执行线程");
    }
}
